<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

// Route::get('/', function () {
//    $webName = config('app.webName');
   
   //获取config目录中的配置信息
   // return $webName;
    // return config('mail.sendmail');

    // 获取.env文件的信息
    // return APP::environment();
    // return env('DB_HOST');

	// config(['app.webName' => 'PHP163的网站']);
	// return config('app.webName');
// });

// Route::get('/test',function()
// {
// 	echo  '这是一个get请求'; 
// });
// Route::get('/form',function(){
// 	return view('/form');
// });
// Route::post('/mytest',function(){
// 	echo '这是一个post请求';
// });
// Route::put('/youtest',function()
// {
// 	echo '这是一个put请求';
// });
// Route::match(['post','get','put','delete'],'/test',function(){
// 	echo 111;
// });

// Route::any('/test',function(){
// 	$url = url('/test');
// 	echo $url;
// });
// Route::get('user/{id}/name/{n}',function($id,$n){
// 	return 'User' . $id. ' ' . $n;
// }); 
// Route::get('user/{id?}/name/{n?}',function($id = 10,$n = 'fds'){
// 	return 'Us er' . $id. ' ' . $n;
// }); 

// Route::get('user/{id?}/name/{n?}',function($id = 10,$n = 'fds'){
// 	return 'User' . $id. ' ' . $n;
// }) -> where(['id' => '[0-9]+' ,  'n' => '[a-zA-Z]+']); 

// Route::get('/',function(){
// 	return view('welcome');
// });

// Route::get('user/profile',[
// 	'as' => 'profile','uses'=> 'UserController@showProfile'
// 	]);

// Route::group(['prefix' => 'user'] ,function(){
// 	Route::get('/add','UserController@add');
// 	Route::get('/delete ','UserController@delete');
// });


//命名空间 
// Route::group(['prefix' =>'/admin/user' ,  'namespace' => 'Admin'],function(){

// 	Route::get('/add','UserController@add');
// 	Route::get('/delete','UserController@delete');
// });


// laravel 书写ajax

// Route::get('/ajax/html',function(){
// 	return view('ajaxhtml');
// });

// Route::post('/ajax/post',function(){
// 	return 111;
// });

//404页面
// Route::get('/404',function()
// {
// 	alert('404');
// });




//中间件

//直接加
// Route::get('/form',function(){
// 	return view('form');
// });

// //第一种方式
// Route::post('/login',['middleware' => 'login',function(){
// 	return 'success';
// }]);


// 第二种方式
// Route::post('/login',['middleware' => 'login','uses' => 'Admin\UserController@login']);


//第三种方式
// Route::post('/login',function(){
// 	return 'success';
// }) -> middleware('login');


// Route::get('/',function(){
// 	return view('welcome');
// });


//控制器内部加中间件
// Route::post('/login','Admin\UserController@login');


//资源控制器
// Route::get('admin/user/add',"Admin\UserController@add");
// Route::get('admin/user/insert',"Admin\UserController@insert");
// Route::get('admin/user/update',"Admin\UserController@update");
// Route::get('admin/user/delete',"Admin\UserController@delete");
// Route::get('admin/user/index',"Admin\UserController@index");


//太麻烦上面的

//一步解决
// Route::resource('photos','Admin\PhotosController');




//隐式控制器
// Route::get('/form',function(){
// 	return view('form');
// });
// Route::controller('/admin/goods','Admin\GoodsController');

//请求
// Route::get('/form',function(){
// 	return view('form');
// }); n
// Route::post('/request/test',"Admin\RequestController@test");

//cookie
// Route::get('/request/wcookie',"Admin\RequestController@wcookie");
// Route::get('/request/cookie',"Admin\RequestController@cookie");

//文件上传
// Route::post('/request/file','Admin\RequestController@file');

Route::get('/',function(){
	return view('welcome');
});

 //使用自定义函数
// Route::get('/test',function(){
// 	myTest();
// });


//后台首页
Route::get('/admin/index',"Admin\IndexController@index");

//用户管理
//资源控制器
// Route::resource('user','Admin\UserController');

Route::get('/admin/user/add','Admin\UserController@add');
Route::post('/admin/user/insert','Admin\UserController@insert');
Route::get('/admin/user/index','Admin\UserController@index');
Route::post('/admin/user/ajaxStatus','Admin\UserController@ajaxStatus');
Route::post('/admin/user/ajaxName','Admin\UserController@ajaxName');
Route::get('/admin/user/edit/{id}','Admin\UserController@edit');
Route::get('/admin/user/delete/{id}','Admin\UserController@delete');
Route::post('/admin/user/update','Admin\UserController@update');


//分类路由

Route::resource('admin/category','Admin\categoryController');

